<template>
	<div class="regBox" v-if="is_show">
		<div class="regBox_pub"></div>
		<div class="regBox_main">
			<b>{{$t('h_pcverifybox.title1')}}</b>
			<div class="forms" >
				<img class="verImg" @click="reloadImg" :src="imgUrl" >
				 
				<el-input :placeholder="$t('h_pcverifybox.title2')" v-model="code">
					<i slot="prefix" class="el-input__icon el-icon-s-custom"
						style="color: var(--theme-text-color-lighten);"></i>
				</el-input>
				
				<button class="submit" @click="submit">{{$t('h_pcverifybox.title3')}}</button>
			</div>
			<div class="closeBtn" @click="close">
				
			</div>
		</div>
		
		
	</div>
</template>

<script>
	export default {
		data() {
			return {
				is_show:false,
				step:0,
				checked:true,
				imgUrl:'',
				code:'',
				key:'',
				ret:()=>{}
			};
		},
		created() {
			this.reloadImg()
		},
		methods: {
			reloadImg(){
				const loading = this.$loading({
				    lock: true,
				    text: 'Loading',
				    spinner: 'el-icon-loading',
				    background: 'rgba(0, 0, 0, 0.7)'
				});
				this.$api.loginVerify(this.formData,(res)=>{
					loading.close();
					if(res.code == 0){
						this.key = res.data.key
						this.imgUrl = res.data.pic
					}else{
						console.log(res,'verify')
						// this.$message.error(res.msg);
					}
				})
			},
			open(ret){
				this.reloadImg()
				this.code = ''
				this.key = ''
				this.ret = ret
				this.is_show = true
			},
			close(){
				this.is_show = false
			},
			submit(){
				this.ret(this.code,this.key)
				this.close()
			},
		}
	}
</script>

<style lang="less" scoped>
	.regBox {
		position: fixed;
		z-index: 1011;
		width: 100vw;
		height: 100vh;
		overflow-y: overlay;
		top:0;
		left: 0;
		
		.closeBtn{
			position: absolute;
			border-radius: 50%;
			z-index: 3;
			bottom: -.9rem;
			left: 0;
			right: 0;
			margin: auto;
			width: 0.5984rem;
			height: 0.5984rem;
			background-image: url(/icons/main.png);
			background-position: -5.1136rem -4.2024rem;
			background-size: 8.296rem 7.7928rem;
		}
		&_pub {
			position: fixed;
			z-index: 1;
			width: 100vw;
			height: 100vh;
			width: 100vw;
			height: 100vh;
			background: rgba(0, 0, 0, .6);
		}

		&_main {
			position: absolute;
			z-index: 2;
			background-color: var(--theme-main-bg-color);
			border: thin solid;
			border-color: var(--theme-color-line);
			border-radius: 0.2rem;
			position: absolute;
			top: 26vh;
			left: 0;
			right: 0;
			width: 6rem;
			height: 5.4rem;
			margin: auto;
			
			.forms {
				max-height: 7rem;
				overflow-x: hidden;
				overflow-y: overlay;
				padding: 0 0.36rem;
				display: flex;
				flex-direction: column;
				.pagemsg{
					max-height: 4.6rem;
					overflow-y: overlay;
					color: var(--theme-text-color);
					font-size: .2rem;
					margin-bottom: .3rem;
				}
				
				.verImg{
					width: 4rem;
					margin: 0 auto;
					border-radius: .2rem;
					margin: .3rem auto;
				}
				
			}
			.el-input{
				margin: 0 0 .32rem;
			}
			p {
				font-size: .18rem;
				height: 0.4rem;
				line-height: 1;
				color: var(--theme-secondary-color-error);
				margin: .16rem 0 .06rem .16rem;
				opacity: .7;
			}

			b {
				margin: 0.4rem 0 0.1rem;
				color: var(--theme-text-color-darken);
				font-size: .26rem;
				font-weight: 700;
				height: 0.34rem;
				display: block;
				text-align: center;
			}
			.msg{
				display: flex;
				margin-bottom: .3rem;
				span{
					font-size: .26rem;
					color: var(--theme-text-color-lighten);
					margin: 0 0 0 .1rem ;
				}
				i{
					font-size: .26rem;
					font-style: normal;
					color: var(--theme-primary-color);
				}
			}
			.submit{
				background-color: var(--theme-primary-color);
				border-color: var(--theme-primary-color);
				border-radius: 0.14rem;
				height: .8rem;
				line-height: .8rem;
				display: block;
				color: var(--theme-primary-font-color);
				font-size: .24rem!important;
			}
			.aas{
				display: flex;
				margin: .3rem 0;
				span{
					flex: 1;
					display: block;
					text-align: center;
					font-size: .24rem;
					color: var(--theme-primary-color);
				}
			}
		}
	}
</style>